<template>
  <div>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="活动名称">
        <el-input v-model="form.loaginName"></el-input>
      </el-form-item>
      <el-form-item label="活动名称">
        <el-input v-model="form.loginPassword"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onLogin">登陆</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import loginApi from "@/api/login";
export default {
  name: "Login",
  data() {
    return {
      form: {
          loaginName:'',
          loginPassword:''
      },
    };
  },
  components: {},
  methods: {
    onLogin() {
      let param = {
        loginName: 'root',
        loginPassword: 'root',
      };
      loginApi.login(param).then((response) => {
        console.log(response)
        if (response.data) {
          localStorage.token=response;
          if(this.$route.query.redirect);
          let redirect = this.$route.query.redirect;
          this.$route.push(redirect);
        }else {
          this.$route.push({name:'DeviceList'});
        }
      });
    },
  },
};
</script>